﻿@model FineAdmin.Web.Areas.SysSet.Models.WebModel
@using FineAdmin.Model;
@{ ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutSysSetPage.cshtml";
    var ActivityList = ViewBag.ActivityList as List<ItemsDetailModel>;
    }

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">

            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                <legend>活动转链</legend>
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <label class="layui-form-label">活动物料ID</label>
                        <div class="layui-input-inline">
                            <input id="activity_material_id" type="text" name="" lay-verify="" placeholder="" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-input-inline">
                            <select name="" lay-filter="activityid">
                                @foreach (var item in ActivityList)
                                {
                                <option value="@item.ItemCode">@item.ItemName</option>
                                }
                            </select>
                        </div>
                        <div class="layui-input-inline">
                            <button type="button" class="layui-btn layui-btn-normal" id="activity_info_get">转</button>
                        </div>
                    </div>
                  
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">通用结果展示</label>
                        <div class="layui-input-block">
                            <textarea placeholder="结果展示" class="layui-textarea" id="result"></textarea>
                        </div>
                    </div>
                </form>
            </fieldset>
        </div>
    </div>
</div>
<script>
    layui.use(['jquery','layer', 'form'], function () {
        var layer = layui.layer
            , form = layui.form
            , $ = layui.$;

        form.on('select(activityid)', function (data) {
            console.log(data.elem); //得到select原始DOM对象
            console.log(data.value); //得到被选中的值
            console.log(data.othis); //得到美化后的DOM对象
            $("#activity_material_id").val(data.value);
        });    

        $("#activity_info_get").click(function () {
            $.ajax({
                url: "/Shop/TBKTools/Activity_Info_Get",
                data: { activity_material_id: $("#activity_material_id").val()},
                type: "Post",
                dataType: "json",
                success: function (rs) {
                    console.log(rs);
                    $("#result").val(JSON.stringify(rs));
                },
                error: function (rs) {
                    console.log(rs);
                    $("#result").val(JSON.stringify(rs));
                }
            });
        });
    });
</script>
